const app = getApp()
var queryUrl = app.globalData.queryUrl;
var start;
var QQMapWX = require('../../../utils/qqmap-wx-jssdk.min.js');
var qqmapsdk;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentData: 0,
    textFlag: false,
    text: "自今年以来，中国和俄罗斯在经贸合作上不断加深。上个月，中国宣布允许俄罗斯全境大豆出口至华。随后，该国大豆供应商向中国运送的首批4400吨大豆也已经成功抵华。在大豆对华出口顺利进行之时，俄罗斯又看向了中国另一大农产品市场,自今年以来，中国和俄罗斯在经贸合作上不断加深。上个月，中国宣布允许俄罗斯全境大豆出口至华。随后，该国大豆供应商向中国运送的首批4400吨大豆也已经成功抵华。在大豆对华出口顺利进行之时，俄罗斯又看向了中国另一大农产品市场",
    latitude: '',
    longitude: '',
    markers: [
      {
        id: 0,
        latitude: 24.7555700000,
        longitude: 118.0824000000,
        iconPath: "../../../images/img6.png",
        width: 70,
        height: 70,
        callout: {

        }
      },
    ],
    head:{}
  },
  toaddress: function (e) {
    console.log(e)
    var id = e.markerId
    console.log(id)
  },
  addheight: function () {
    this.setData({
      textFlag: !this.data.textFlag
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var shopId = options.shopId
    // var latitude = options.latitude
    // var longitude = options.longitude
    try {
      var openId = wx.getStorageSync('openId')
    } catch (e) { }
    qqmapsdk = new QQMapWX({
      key: 'USJBZ-3LH6D-JWD4K-PYRYA-3DR32-SMBVJ' // 必填
    });
    wx.request({
      url: queryUrl + 'selectShop',
      data: {
        // id:shopId  //传参
        id: "1",
        opendId: openId,
      },
      method: 'post',
      success: function (res) {
        console.log(res.data.data)
        that.setData({ head: res.data.data.shop[0] })
      }
    })
  },
  setMapHeight: function (params) {
    var that = this;
    that.setData({
      mapHeight: (windowHeight - bottomHeight) + 'px'
    })
    // var controlsWidth = 40;
    // var controlsHeight = 48;
    //设置中间部分指针
    that.setData({
      controls: [{
        id: 1,
        iconPath: '../../../images/img6.png',
        position: {
          left: (windowWidth - controlsWidth) / 2,
          top: (windowHeight - bottomHeight) / 2 - controlsHeight * 3 / 4,
          width: controlsWidth,
          height: controlsHeight
        },
        clickable: true
      }]
    })
  },

  //获取当前滑块的index
  bindchange: function (e) {
    let that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
  //点击切换，滑块index赋值
  checkCurrent: function (e) {
    let that = this;
    var current = that.data.currentData
    var en = e.target.dataset.current
    if (current === en) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
    }
    if (en == "1") {
      let that = this;
      wx.request({
        url: queryUrl + 'recruit/select',
        data: {
          shopId: "1",
        },
        method: 'post',
        success: function (res) {
          console.log(res.data)
          that.setData({ posits: res.data.data.recruit })
        }
      })
    }
  },
  navigateBack: function () {
    wx.switchTab({
      url: "../index/index"
    });    
  }
})